﻿using JiebaNet.Segmenter;
using JiebaNet.Segmenter.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JieBa.NET
{
    internal class Program
    {
        static void Main(string[] args)
        {
            MyDbContext db = new MyDbContext();
          //  List<Position> positions = db.positions.Where(x => x.searchKeyWord == ".NET").ToList();
            List<Position> positions = db.positions.ToList();
            StringBuilder sb = new StringBuilder();
            foreach (var item in positions)
            {
                sb.Append(item.descriptText.Replace(" ", "").Replace("\n","").Replace("微信分享",String.Empty));
            }
            // string str = sb.Replace(" ","").ToString();
            // Console.WriteLine(sb.ToString(),Encoding.UTF8);

            var seg = new JiebaSegmenter();
            var segs = seg.Cut(sb.ToString());
            //Console.WriteLine(string.Join(" ",segs));
            string str = string.Join(" ", segs);
            string[] vs = str.Split(' ');
            vs = vs.Union(vs).ToArray();

            using (StreamWriter sw = new StreamWriter("mydict.txt"))
            {
                foreach (string s in vs)
                {
                    sw.WriteLine(s);

                }
            }
            foreach (var item in vs)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("success");
            Console.ReadKey();
        }
    }
}
